import axiosInstance from "../axiosInstance.js";


const categoryInfo = {
    /**
     * 菜品分类分页查询
     * @param {{pageIndex,category_name}} param0 
     * @returns {Promise<Object>}
     */
    getListByPage({ pageIndex, category_name }) {
        return axiosInstance.get("/categoryInfo/getListByPage", {
            params: {
                pageIndex, category_name
            }
        })
    },
    /**
     * 根据id删除某一类菜品
     * @param {id} id 
     * @returns {Promise<Object>}
     */
    deleteById(id) {
        return axiosInstance.get("/categoryInfo/deleteById", {
            params: {
                id
            }
        })
    },
    /**
     * 新增菜品分类
     * @param {{category_name}} param0 
     * @returns {Promise<Object>}
     */
    add({ category_name }) {
        return axiosInstance.get("/categoryInfo/add", {
            params: {
                category_name
            }
        })
    },
    /**
     * 获取所有菜品的分类信息
     * @returns {Promise<Object>}
     */
    getAllList() {
        return axiosInstance.get("/categoryInfo/getAllList");
    },
    /**
     * 根据id得到菜品分类信息
     * @param {id} param0 
     * @returns {Promise<Object>}
     */
    findById(id) {
        return axiosInstance.get("/categoryInfo/findById", {
            params: {
                id
            }
        })
    },
    /**
     * 更新菜品分类
     * @param {{id,category_name}} param0 
     * @returns 
     */
    update({ id, category_name }) {
        return axiosInstance.post("/categoryInfo/update", {
            id, category_name
        })
    }
}

export default categoryInfo;